﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RN.ERP.Web.BasicService;

namespace RN.ERP.Web.UserControl
{
    public partial class UCArea : System.Web.UI.UserControl
    {
        private string _setArea;
        //public string SetArea
        //{
        //    set
        //    {
        //        _setArea = value;
        //    }
        //}

        //public string SelectedArea
        //{
        //    get
        //    {
        //        return hidCode.Value;
        //    }
        //}

        /// <summary>
        /// 获取或设置控件的地区编号。
        /// </summary>
        public string AreaCode
        {
            get
            {
                return hidCode.Value;
            }
            set
            {
                _setArea = value;
                //hidCode.Value = _setArea;
            }
        }
        private bool _enable = true;
        public bool Enable
        {
            get
            {
                return _enable;
            }
            set
            {
                _enable = value;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(_setArea))
            {
                hidCode.Value = _setArea;
                BasicServiceClient client = new BasicServiceClient();
                lblAdress.Text = client.GetAddress(hidCode.Value);
            }
            if (!IsPostBack)
            {
                imgClose.ImageUrl = "~/Images/deleteicon00.jpg";

                hdnEnable.Value = (Enable ? 0 : 1).ToString();
                if (!Enable)
                {
                    lblAdress.Enabled = false;
                }
            }
        }
    }
}